package com.ply.service.impl;

import com.ply.entity.vo.Result;
import com.ply.mapper.AccountRecordMapper;
import com.ply.service.AccountRecordService;
import org.springframework.stereotype.Service;

/**
 * @author XiaoPan
 * date: 2022/1/7 15:56
 * <p>
 * action: 账户流水记录表
 */
@Service
public class AccountRecordServiceImpl implements AccountRecordService {
    private final AccountRecordMapper accountRecordMapper;

    public AccountRecordServiceImpl(AccountRecordMapper accountRecordMapper) {
        this.accountRecordMapper = accountRecordMapper;
    }

    /**
     * 写入数据库 流水记录
     *
     * @param userId
     * @param amount
     */
    public Result addAccountRecord(int userId, double amount) {
        int i = accountRecordMapper.addAccountRecord(userId, amount);

        if (i == 0) {
            return Result.fail("数据库 失败 流水记录增加失败");
        }
        return Result.ok();
    }
}
